package sanrenxing.dayEnd.backRepertoryTotal.dao;

import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import sanrenxing.dayEnd.backRepertoryTotal.domain.CashStockLXF;

import java.util.List;

/**
 * @desrciption 现金存库dao层
 * @auth：yidu  李小锋
 * @date:2021/3/13 0013 - 11:06
 * @version:1:0
 */
@Repository //标识为Spring中的Bean
public interface CashStockDaoLXF {
    /**
     * 新增一行数据
     * @param cashStock 对象
     * @return 0、增加失败 1、增加成功values(#{rightsId},#{seId},to_date('${rigDay}','yyyy-MM-dd'),to_date('${righDay}','yyyy-MM-dd'),to_date('${dueDate}','yyyy-MM-dd'),#{rigType},#{pro},#{proState},to_date('${businDate}','yyyy-MM-dd'))
     */
    @Insert("insert into cashStock(cashId,fundId,caId,caMoney,time)" +
            " values(seqCashStock.nextval,#{fundId},#{caId},#{caMoney},#{time})")
    public int add(CashStockLXF cashStock);
    /**
     * 删除一行数据
     * @param cashId 编号
     * @return 0、删除失败 1、删除成功
     */
    @Delete("delete from cashStock where cashId=#{cashId}")
    public int delete(@Param("cashId") int cashId);
    /**
     * 修改一行数据
     * @param cashStock 对象
     * @return 0、修改失败 1、修改成功
     */
    @Update("update cashStock set fundId=#{fundId},caId=#{caId},caMoney=#{caMoney},time=#{time},securNum=#{securNum}" +
            "where cashId=#{cashId}")
    public int update(CashStockLXF cashStock);
    /**
     * 查询所有的订单数据
     * @return 返回一个订单集合
     */
    @Select("select * from cashStock")
    @Results(id = "cashMap",value = {
            @Result(id = true,column = "cashId",property = "cashId"),
            @Result(column = "caId",property = "caId"),
            @Result(column = "fundId",property = "fundId"),
            @Result(column = "caMoney",property = "caMoney"),
            @Result(column = "time",property = "time"),
            @Result(column = "securNum",property = "securNum")
    })
    public List<CashStockLXF> findAll();
    /**
     * 分页查询
     * @param start  开始行号
     * @param rows   每页行数
     * @param condition 查询条件
     * @return 集合
     */
    @ResultMap(value = "cashMap")
    @Select("<script>"+
            "select * from " +
                "(select rownum  rn,cashStock.* from cashStock " +
                "<where> #{rows}>rownum </where>)"+
                "<where>"+
                /*"<if test='rn!=0'>"+*/
                " ${condition}"+
                /*"</if>"+*/
                " and rn>=#{start}"+
                "</where>"+
            "</script>")
    public List<CashStockLXF> findByPage(@Param("start") int start, @Param("rows") int rows, @Param("condition") String condition);
    /**
     * 按条件统计出记录行数
     * @param condition 条件
     * @return 记录行数
     */
    @Select("select count(*) from cashStock where 1=1  ${condition}")
    public int count(@Param("condition") String condition);
}
